﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>overview service test</title>

	<script src="../Shared/Scripts/jquery.js" type="text/javascript"></script>

	<script src="OverviewServiceProxy.js" type="text/javascript"></script>

</head>
<body>
	
	<button id="poll" value="poll">poll for results</button>

	<div id="text"></div>

	<script type="text/javascript">

		$j("#text").ready(function ()
		{
			var proxy = new PowerTools2011.Services.OverviewServiceProxy();
			var procId = null;
			var text = $j("#text");

			proxy.calculate("tcm:0-5-1", function (response)
			{
				//console.debug(response);

				text.append("<p>response: " + response.d.Message + "</p>");

				procId = response.d.ProcessId;
			});

			$j("#poll").click(function ()
			{
				proxy.getProcessStatus(procId, function (response)
				{
					//console.debug(response);
					text.append("<p>percent: " + response.d.PercentComplete + "</p>");

					if (response.d.PercentComplete == 100)
					{
						proxy.getResult(procId, function (result)
						{
							var r = result.d.Result;
							var types = r.CalculatedTypes;

							text.append("<p>calculated " + types.length + " types</p>");
							text.append("<p>calculated " + r.TotalItems + " total items</p>");
						});
					}
				});
			});
		});
	</script>

</body>
</html>
